#ifndef __RTC_MISC_H__
#define __RTC_MISC_H__

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

#include "utc_clock.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)

typedef struct _rtc_time
{
    uint16_t year;
    uint8_t month;
    uint8_t day;
    uint8_t hour;
    uint8_t minute;
    uint8_t second;
    uint8_t wday;
    int8_t time_zone;
}rtc_time_t;

typedef UTCTimeStruct rtc_struct_t;

// ##
void rtc_to_time(uint32_t *time, rtc_time_t *tm);

// ##
uint32_t time_to_rtc(const rtc_time_t *tm);

// ##
uint32_t rtc_utc_get(void);

// ##
uint64_t rtc_utc_ms_get(void);

// ##
uint64_t rtc_get_active_ms(void);

// ##
bool rtc_time_get(rtc_struct_t *val);

#ifdef __cplusplus
}
#endif

#endif /* __RTC_MISC_H__ */
